#ifndef STACK_H
#define STACK_H

#include "common.h"

#define STACK_SIZE 256

template< class T >
class Stack
{
    T mData[STACK_SIZE];
    int mCounter;
public:
    Stack():mCounter(0){}

    void push( T rElement )
    {
        if( mCounter > STACK_SIZE )
        {
            Exception e("Stack Overflow");
            throw e;
        }

        mData[mCounter++] = rElement;
    }

    T pop()
    {
        if( mCounter <= 0 )
        {
            Exception e("Stack Underflow");
            throw e;
        }

        return mData[--mCounter];
    }

    int empty() const { return mCounter<=0; }

};

#endif // STACK_H
